home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / mgr / sparcmgr / src.zoo / src / get_rect.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-17  |  2.1 KB  |  78 lines

  1. /*                        Copyright (c) 1987 Bellcore
  2.  *                            All Rights Reserved
  3.  *       Permission is granted to copy or use this program, EXCEPT that it
  4.  *       may not be sold for profit, the copyright notice must be reproduced
  5.  *       on copies, and credit should be given to Bellcore where it is due.
  6.  *       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  7.  */
  8. /*    $Header: get_rect.c,v 1.1 89/03/17 08:21:10 sau Exp $
  9.     $Source: /m1/mgr.new/src/RCS/get_rect.c,v $
  10. */
  11. static char    RCSid_[] = "$Source: /m1/mgr.new/src/RCS/get_rect.c,v $$Revision: 1.1 $";
  12.  
  13. /* sweep out a rectangle */
  14.  
  15. #include "bitmap.h"
  16. #include "defs.h"
  17.  
  18. #define Box(screen,x,y,dx,dy) \
  19.     type ? \
  20.            bit_line(screen,x,y,x+dx,y+dy,BIT_NOT(BIT_DST)) : \
  21.            box(screen,x,y,dx,dy) 
  22.  
  23.  
  24. get_rect(screen,mouse,x,y,dx,dy,type)
  25. BITMAP *screen;        /* where to sweep out the box */
  26. int mouse;            /* file to get mouse coords from */
  27. int x,y;            /* starting position */
  28. register int *dx,*dy;        /* box width,height */
  29. int type;            /* rectangle or line */
  30.    {
  31.    int x_mouse, y_mouse;
  32.    register int button;
  33.    register int newx;
  34.    register int newy;
  35.    register int skip=1;
  36.  
  37.    newx = *dx;
  38.    newy = *dy;
  39.  
  40.    Box(screen,x,y,*dx,*dy);
  41.    do {
  42.       button=mouse_get(mouse,&x_mouse,&y_mouse);
  43.       if (skip)
  44.          Box(screen,x,y,*dx,*dy);
  45.       newx += x_mouse<<1;
  46.       newy -= y_mouse<<1;
  47.       *dx = BETWEEN(-x,newx,(int) BIT_WIDE(screen)-x);
  48.       *dy = BETWEEN(-y,newy,(int) BIT_HIGH(screen)-y);
  49.       if (skip = !mouse_count())
  50.          Box(screen,x,y,*dx,*dy);
  51.       }
  52.    while (button!=0);
  53.  
  54.    if (skip)
  55.       Box(screen,x,y,*dx,*dy);
  56.    }
  57.  
  58. /* draw a box */
  59.  
  60. box(screen,x1,y1,dx,dy)
  61. BITMAP *screen;
  62. int x1,y1,dx,dy;
  63.    {
  64.    if (dx<0)
  65.       x1 += dx,dx = -dx;
  66.    if (dy<0)
  67.       y1 += dy,dy = -dy;
  68.    if (dx<3)
  69.       dx=3;
  70.    if (dy<3)
  71.       dy=3;
  72.  
  73.    bit_blit(screen,x1+1,y1,dx-1,1 ,BIT_NOT(BIT_DST),NULL_DATA,0,0);
  74.    bit_blit(screen,x1+1,y1+dy,dx-1,1 ,BIT_NOT(BIT_DST),NULL_DATA,0,0);
  75.    bit_blit(screen,x1,y1,1, dy,BIT_NOT(BIT_DST),NULL_DATA,0,0);
  76.    bit_blit(screen,x1+dx,y1,1, dy,BIT_NOT(BIT_DST),NULL_DATA,0,0);
  77.    }
  78.